load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "txn",
    srcs = [
        "batch_getter.go",
        "binlog.go",
        "error.go",
        "scanner.go",
        "snapshot.go",
        "txn_driver.go",
        "union_iter.go",
        "unionstore_driver.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/store/driver/txn",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/sessionctx/binloginfo",
        "//pkg/store/driver/error",
        "//pkg/store/driver/options",
        "//pkg/table/tables",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/logutil",
        "//pkg/util/tracing",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_pingcap_tipb//go-binlog",
        "@com_github_tikv_client_go_v2//error",
        "@com_github_tikv_client_go_v2//kv",
        "@com_github_tikv_client_go_v2//tikv",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@com_github_tikv_client_go_v2//tikvrpc/interceptor",
        "@com_github_tikv_client_go_v2//txnkv",
        "@com_github_tikv_client_go_v2//txnkv/transaction",
        "@com_github_tikv_client_go_v2//txnkv/txnsnapshot",
        "@com_github_tikv_client_go_v2//txnkv/txnutil",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "txn_test",
    timeout = "short",
    srcs = [
        "batch_getter_test.go",
        "driver_test.go",
        "main_test.go",
        "union_iter_test.go",
    ],
    embed = [":txn"],
    flaky = True,
    shard_count = 5,
    deps = [
        "//pkg/kv",
        "//pkg/testkit/testsetup",
        "//pkg/util/mock",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_kvproto//pkg/kvrpcpb",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_uber_go_goleak//:goleak",
    ],
)
